package com.sanmubird.mywebframework.embeddeddatabase.config;

import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author sam
 */
@Configuration
public class ServeConfiguration {
    @Value("${mariadb.args}")
    private String dbArgs;

    @Value("${mariadb.port}")
    private int port;

    public ServeConfiguration() {
    }

    /**
     * 这个类 会启动 mariaDB4j
     */
    @Bean
    public MariaDB4jSpringService mariaDB4j() {
        MariaDB4jSpringService service = new MariaDB4jSpringService();
        DBConfigurationBuilder configuration = service.getConfiguration();
        configuration.setPort(port);
        configuration.addArg(this.dbArgs);
        return service;
    }
}